home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / fundiv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  781 b   |  37 lines

  1. /*
  2. \funcref{fun\_div}{void fun\_div ()}
  3.     {}
  4.     {}
  5.     {pop(), push(), error()}
  6.     {}
  7.     {fundiv.c}
  8.     {
  9.         This function pops two variables and pushes the quotient of the {\em
  10.         vu.intval} fields of these variables. The resulting pushed variable is
  11.         of type {\em e\_int}.
  12.  
  13.         It is assumed that the left argument of the division was pushed first;
  14.         therefore, the right argument is popped first. A division by zero leads
  15.         to an error.
  16.     }
  17. */
  18.  
  19. #include "icm-exec.h"
  20.  
  21. void fun_div ()
  22. {
  23.     VAR_
  24.         tmp;
  25.     int
  26.         rvalint;
  27.  
  28.     tmp.type = e_int;
  29.     rvalint = pop ().vu.intval;
  30.     if (! rvalint)
  31.         error ("divide by zero at %s", hexstring (curoffs, 4));
  32.  
  33.     tmp.vu.intval = pop().vu.intval / rvalint;
  34.  
  35.     push (tmp);
  36. }
  37.